package reaction.news;

import java.io.File;
import java.io.IOException;

import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;

import reaction.news.index.MyPortugueseAnalyzer;
import de.tudarmstadt.ukp.wikipedia.api.DatabaseConfiguration;
import de.tudarmstadt.ukp.wikipedia.api.WikiConstants.Language;
import de.tudarmstadt.ukp.wikipedia.api.Wikipedia;
import de.tudarmstadt.ukp.wikipedia.api.exception.WikiInitializationException;

public class Definitions {
	
	/* Lucene stuff */
	public static String newsIndexLocation = "publico.pt"; 							// publico.pt  index
	public static String wikipediaIndexLocation = "/srv/dsbatista/WikipediaIndex";	// WikipediaPT index
	public static Directory newsIndexDirectory;
	public static Directory wikipediaIndexDirectory;
	public static IndexSearcher newsSearcher;
	public static IndexSearcher wikipediaSearcher;
	
	public static MyPortugueseAnalyzer analyzer = new MyPortugueseAnalyzer(Version.LUCENE_35);
	
	/* Access to JWPL Wikipedia */
	public static DatabaseConfiguration dbConfig;
	public static Wikipedia wiki;
	
	/* MySQL user/pass */
	public static String username = "";
	public static String password = "";
	
	public static void init() throws CorruptIndexException, IOException {
		
		/* publico.pt Lucene Index */
		//newsIndexDirectory = FSDirectory.open(new File(newsIndexLocation));
		//newsSearcher = new  IndexSearcher((IndexReader.open(newsIndexDirectory)));
		
		/* WikipediaPT Lucene Index */
		wikipediaIndexDirectory = FSDirectory.open(new File(wikipediaIndexLocation));
		wikipediaSearcher = new  IndexSearcher((IndexReader.open(wikipediaIndexDirectory)));
		
		/* JWPL: Portuguese Wikipedia Structure 
		try {
			
			// configure the database connection parameters
			dbConfig = new DatabaseConfiguration();
			dbConfig.setHost("reactionvm01");
			dbConfig.setDatabase("JWLPWikiPT");
			dbConfig.setUser("monty");
			dbConfig.setPassword("");
			dbConfig.setLanguage(Language.english);

			// Create the Wikipedia object
			wiki = new Wikipedia(dbConfig);
			
		} catch (WikiInitializationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
	}
}
